﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        warning.Visible = false;
        GetQueryString();
    }

    public void GetQueryString()
    {
        string queryString = Request.QueryString["action"];       
 
        if (queryString == "logout")
        {
            Logout();
        }
        else if (queryString == "user")
        {
            tpxUser.Visible = true;
        }
        else if (queryString == "product")
        {
            Response.Redirect("product.aspx");
        }
        else if (queryString == "categoryList")
        {
            tpxCategoryList.Visible = true;
        }
        else if (queryString == "category")
        {
            tpxCategory.Visible = true;
        }
        else if (queryString == "insertproduct")
        {
             tpxInsertProduct.Visible=true;
        }
        else if (queryString == "InsertManuFacture")
        {
            tpxInsertManu.Visible = true;    
        }else if(queryString == "feedback")
        {
            tpxFeedBack.Visible = true;
        }
        else if (queryString == "manufacture")
        {
            Response.Redirect("ManuFacture.aspx");
        }
        else 
        {
            tpxHome.Visible = true;
        }
    }

    public void GetErrorString()
    {
        string errorQuery = Request.QueryString["error"];
        string errorString = "";

        if (errorQuery != null || errorQuery != "")
        {
            if (errorQuery == "100")
            {
                errorString = "Sai tên đăng nhập hoặc mật khẩu.";
            }
            
            if (errorString != "")
            {
                warning.Visible = true;
                lblError.Text = errorString;
            }            
        }
    }

    public void Logout()
    {
        Session["username"] = "";
        Response.Redirect("default.aspx");
    }
}